Skip to content

Load Parquet page indexes after Bloom filter pruning - #233

Open
aman-ddog wants to merge 2 commits into
den-55from
aman/parquet-pageindex-after-bloom
Open

aman-ddog wants to merge 2 commits into
den-55from
aman/parquet-pageindex-after-bloom

Conversation

@aman-ddog

Copy link
Copy Markdown

Why

The Parquet opener currently loads the page index (column index + offset index) right after row-group statistics pruning, and only then loads and applies Bloom filters. If Bloom filters prune every remaining row group, or leave only row groups that statistics already fully match, the page index fetch was wasted: an extra I/O request plus decoding work that pruning never uses. This matters most for selective point lookups (col = value) on files with Bloom filters, where statistics often keep a row group but Bloom filters remove it.

What changed

  • Opener order is now PruneWithStatistics → LoadBloomFilters → PruneWithBloomFilters → LoadPageIndex? → BuildStream.
    • The decision to load the page index moves to after Bloom filter pruning, so it only considers row groups that survived both steps.
    • It is skipped when no row group survives, when all survivors are fully matched, or when no page pruning predicate applies.
  • No refetch when the page index is already in memory.
    • If the loaded metadata already has both column and offset indexes (for example, served by a metadata cache), the opener goes straight to BuildStream.
  • "All row groups skipped" is treated as nothing to scan.
    • New RowGroupAccessPlanFilter::has_remaining_row_groups() replaces !is_empty() checks, which returned true for access plans whose slots were all Skip.
    • Bloom filter loading, Bloom pruning, and page-level pruning now do nothing when no row group survives.
  • page_index_load_skipped metric.
    • Now counts skips caused by statistics or Bloom pruning. It is not incremented when the page index was already loaded.
  • Diff breakdown (~94% tests).
    • Production: +56 / −33 lines (opener state machine, one row-group filter helper, one metric doc comment).
    • Tests: +842 lines. They include an I/O-recording reader factory that checks page index byte ranges against Bloom filter byte ranges.

Scope & caveats

  • Query results are unchanged. No new configuration. Bloom and page index pruning still respect their existing enable_* settings.
  • When Bloom filters prune nothing, the I/O is the same, just in a different order. Bloom filters are read first, then the page index.
  • The page index is still loaded for the whole file when any surviving row group needs it. It is not limited to the survivors.
  • Planning-time paths are unchanged. Schema and statistics inference paths that preload metadata with page indexes before the opener runs work as before. The opener sees the existing page index and does not fetch it again.
Verification
  • New tests cover: Bloom prunes all row groups (with and without a metadata cache), Bloom keeps a subset (the last Bloom read happens strictly before the first page index read, with pushdown_filters on and off), Bloom leaves only fully matched row groups, a page index preloaded in cached metadata, page index disabled, Bloom disabled, statistics pruning every row group, an empty file, and an all-Skip access plan.
  • cargo fmt --all -- --check: passed.
  • cargo clippy -p datafusion-datasource-parquet --all-targets --all-features -- -D warnings: passed.
  • cargo test -p datafusion-datasource-parquet (with PARQUET_TEST_DATA): 225/225 unit tests passed, 4/4 doctests passed (5 pre-existing ignored doctests).
  • Full workspace extended tests: CI only (not run locally).

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.81306% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.31%. Comparing base (ce3d32c) to head (0add725).

Files with missing lines Patch % Lines
datafusion/datasource-parquet/src/opener/mod.rs 98.80% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           den-55     #233      +/-   ##
==========================================
+ Coverage   81.28%   81.31%   +0.02%     
==========================================
  Files        1111     1111              
  Lines      390523   391176     +653     
  Branches   390523   391176     +653     
==========================================
+ Hits       317453   318095     +642     
- Misses      54448    54460      +12     
+ Partials    18622    18621       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants